package com.vcredit.creditcat.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.vcredit.creditcat.model.ChannelBusinessStatus;
import com.vcredit.creditcat.framework.pagination.Criteria;
import com.vcredit.creditcat.framework.pagination.Page;
import com.vcredit.creditcat.persistence.base.ChannelBusinessStatusMapper;

 /*
  * @author liaoshengjun
  * @version 1.0
  * @since 1.0
 */
@Service
public class ChannelBusinessStatusService {
    
    @Autowired
	private ChannelBusinessStatusMapper channelBusinessStatusMapper;
    
	public Page<ChannelBusinessStatus> findByPage(Criteria criteria){
	    return new Page<ChannelBusinessStatus>(channelBusinessStatusMapper.findByPageCount(criteria), channelBusinessStatusMapper.findByPage(criteria));
	}
	
	public List<ChannelBusinessStatus> find(ChannelBusinessStatus channelBusinessStatus){
	    return channelBusinessStatusMapper.find(channelBusinessStatus);
	}
	
	public ChannelBusinessStatus findById(Long channelBusinessId){
	    return channelBusinessStatusMapper.findById(channelBusinessId);
	}
	
	public List<ChannelBusinessStatus> findAll(){
	    return channelBusinessStatusMapper.findAll();
	}
	
	public void save(ChannelBusinessStatus channelBusinessStatus){
	  try {
	     channelBusinessStatusMapper.insert(channelBusinessStatus);
       }catch (Exception e) {
           e.printStackTrace();
       }
	}
	
	public void update(ChannelBusinessStatus channelBusinessStatus){
		channelBusinessStatusMapper.update(channelBusinessStatus);
	}
	
	public void removeChannelBusinessStatus(String ids){
	  for (String channelBusinessIdString : ids.split(",")) {
        Long channelBusinessId = Long.parseLong(channelBusinessIdString);
        channelBusinessStatusMapper.delete(channelBusinessId);
      }
	}
	
}
